package oc.tm.sg.admin.web.service.impl;

import java.util.List;

import org.smart4j.framework.tx.annotation.Service;

import oc.tm.sg.admin.govern.BootstrapGovern;
import oc.tm.sg.admin.web.service.UnsubscribeService;
import oc.tm.sg.registry.common.URL;
import oc.tm.sg.registry.core.NotifyListener;

/**
 * 取消订阅控制器
 * @author lry
 */
@Service
public class UnsubscribeServiceImpl implements UnsubscribeService {
	BootstrapGovern registryContainer=BootstrapGovern.INSTANCE;
    /**
     * 取消订阅
     * @param consumer
     * @return
     */
    public void unsubscribe(String consumer) {
        URL consumerUrl = URL.valueOf(consumer);
        registryContainer.getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
    }

    /**
     * 监听器
     * @author lry
     */
    private static class NotifyListenerAdapter implements NotifyListener {

        public static final NotifyListener NOTIFY_LISTENER = new NotifyListenerAdapter();

        private NotifyListenerAdapter() {
        }

        public void notify(List<URL> urls) {
        }

    }
}
